#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int arr[100010];
int n;
int m;
int main()
{
	while (cin >> n >> m)
	{
		for (int i = 0; i < n; i++)
		{
			cin >> arr[i];
		}
		sort(arr, arr + n);
		int count = 0;
		if (m == 0)
		{
			cout << n / 2 << endl;
			break;
		}
		for (int i = 0; i < n - 1; i++)
		{
			int j = i + 1;
			if (abs(arr[i] - arr[j]) < m && arr[i] != 0 && arr[j] != 0)
			{
				count++;
				arr[i] = 0;
				arr[j] = 0;
			}
		}
		cout << count << endl;
	}
	return 0;
}